<template>
<Layout>
  <!-- Page Header -->
  <header class="masthead" :style="{backgroundImage:` url(http://localhost:1337${genertalCompute.cover.url})`}">
    <div class="overlay"></div>
    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-md-10 mx-auto">
          <div class="site-heading">
            <h1>{{genertalCompute.title}}</h1>
            <span class="subheading">{{genertalCompute.subtitle}}</span>
          </div>
        </div>
      </div>
    </div>
  </header>

  <!-- Main Content -->
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-md-10 mx-auto">
        <div class="post-preview" v-for="edges in $page.list.edges" :key="edges.id">
          <g-link :to="'post/'+edges.node.id">
            <h2 class="post-title">
              {{edges.node.title}}
            </h2>
          </g-link>
          <p class="post-meta">
            Posted by
            <a href="#">Start Bootstrap</a>
            on {{edges.node.created_at}}
          </p>
          <p>
            <span v-for="tag in edges.node.tags" :key="tag.id">
              <g-link :to="'tag/'+tag.id"> &nbsp;&nbsp;
                {{tag.title}}
              </g-link>
            </span>
          </p>
          <hr />
        </div>
        <!-- <div class="post-preview">
          <a href="post.html">
            <h2 class="post-title">
              I believe every human has a finite number of heartbeats. I don't
              intend to waste any of mine.
            </h2>
          </a>
          <p class="post-meta">
            Posted by
            <a href="#">Start Bootstrap</a>
            on September 18, 2019
          </p>
        </div>
        <hr />
        <div class="post-preview">
          <a href="post.html">
            <h2 class="post-title">Science has not yet mastered prophecy</h2>
            <h3 class="post-subtitle">
              We predict too much for the next year and yet far too little for
              the next ten.
            </h3>
          </a>
          <p class="post-meta">
            Posted by
            <a href="#">Start Bootstrap</a>
            on August 24, 2019
          </p>
        </div>
        <hr />
        <div class="post-preview">
          <a href="post.html">
            <h2 class="post-title">Failure is not an option</h2>
            <h3 class="post-subtitle">
              Many say exploration is part of our destiny, but it’s actually
              our duty to future generations.
            </h3>
          </a>
          <p class="post-meta">
            Posted by
            <a href="#">Start Bootstrap</a>
            on July 8, 2019
          </p>
        </div>
        <hr /> -->
        <!-- Pager -->
        <Pager :info="$page.list.pageInfo" />
        <!-- <div class="clearfix">
          <a class="btn btn-primary float-right" href="#"
            >Older Posts &rarr;</a
          >
        </div> -->
      </div>
    </div>
  </div>
</Layout>
</template>

<page-query>
query ($page: Int) {
  list: allStrapiPost (perPage: 2, page: $page) @paginate {
    pageInfo {
      totalPages
      currentPage
    }
    edges {
      node {
        id
        title
        created_at
        tags {
          id
          title
        }
      }
    }
  },
  genertal: allStrapiGenertal {
    edges {
      node {
        id
        title
        subtitle
        cover {
          url
        }
      }
    }
  }
}
</page-query>

<script>
import { Pager } from 'gridsome'
export default {
  metaInfo: {
    title: "Hello, world!",
  },
  name: "index",
  computed: {
    genertalCompute() {
      return this.$page.genertal.edges[0].node
    }
  },
  components: {
    Pager
  }
};
</script>

<style></style>
